<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Vue-index</title>
</head>
<body>
<div id="app">
    {{ message }}
    <p :title="title">
        鼠标悬停几秒钟查看此处动态绑定的提示信息！
    </p>
    <hr>
    <ul>
        <li v-for="book in books">{{book.name}}</li>
    </ul>
    <p v-if="flag">我显示啦</p>
</div>
</body>
</html>
<script src="https://cdn.jsdelivr.net/npm/vue"></script>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script type="text/javascript" src="./bower_components/mockjs/dist/mock.js"></script>
<script>
    var vue = new Vue({
        el: '#app',
        data: {
            message: 'Hello Vue!',
            title: '页面加载于 ' + new Date().toLocaleString(),
            books: [],
            flag: true
        },
        methods: {},
        //发送请求
        created() {
            axios.get('/book/list')
                .then(function (res) {
                    this.books = res.data;
                    console.log( this.books[0].name);
                })
                .catch(function (error) {
                    console.log(error);
                });
        }
    })
</script>